// pages/cardtype/cardtype.js
const app = getApp()
const baseUrls = 'http://soundlab.jschunk.com:8085';
var server = require('../../utils/server');
var that
Page({

  /**
   * 页面的初始数据
   */
  data: {
    cardKindID:'',
    picpath:'',
    list:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (e) {
    that = this
    wx.setNavigationBarTitle({
      title: e.kind
    })
    that.setData({
      cardKindID:e.cardKindID,
      picpath:e.picpath
    })
    console.log(e)
    server.requestForm(false, 'get', 'card', {
      filter:{
        cardKindID:e.cardKindID
      },
      sort:{
        createTime:-1
      },
      page:{
        size:6,
        index:1
      }

    }, function (e) {
      console.log(e)
        that.setData({
          list:e.items
        })
    })
  },
  release:function(e){
    if (app.globalData.userID == '') {
      wx.showToast({
        title: '请先去我的里授权登录',
        icon: 'none',
        duration: 1000,
      });
    } else {
      // var picpath = e.currentTarget.dataset.picpath
      // var cardKindID = e.currentTarget.dataset.id
      console.log(e)
      wx.navigateTo({
        url: '../release/release?picpath=' + that.data.picpath + '&cardKindID=' + that.data.cardKindID,
      })
    }
  },
  carddetails: function(e) {
    console.log(e)
    var id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '../carddetails/carddetails?id=' + id,
    })
  },
})